object LeftAndRight {
  def main(args: Array[String]): Unit = {
    //left right

    //模式匹配
    divideBy(100,0) match {
      case Left(s) => println(s)
      case Right(v) => println("right= "+ v)
    }
  }

  def divideBy(x:Int,y:Int):Either[String,Int] = {
    if (y == 0) Left("不能被零除")
    else Right(x / y)
  }
}
